package com.spzx.user.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.user.api.RemoteUserAddressService;
import com.spzx.user.api.RemoteUserBrowseHistoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * ClassName: RemoteUserBrowseHistoryFallbackFactory
 * Package: com.spzx.user.api.factory
 * Description:
 *
 * @Author 梅超凡
 * @Create 2024/12/26 21:05
 * @Version 1.0
 */
@Slf4j
public class RemoteUserBrowseHistoryFallbackFactory implements FallbackFactory<RemoteUserBrowseHistoryService> {
    @Override
    public RemoteUserBrowseHistoryService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteUserBrowseHistoryService() {
            @Override
            public R<Boolean> saveUserBrowseHistory(Long userId,Long skuId, String source) {
                return R.fail("保存用户浏览记录失败:" + throwable.getMessage());
            }
        };
    }
}
